﻿
namespace LeadMaster.Controllers
{
  using System;
  using System.Linq;
  using System.Web.Mvc;
  using LeadMaster.DAL;
  using LeadMaster.ViewModels;
  using System.Web.Security;
  using LeadMaster.Helpers;
  using System.Collections.Generic;
  using LeadMaster.Models;
  using System.Data;
  using LeadMaster.Properties;
  using System.Configuration;
  using System.Data.Entity;
  using System.Data.Entity.Core.Objects;
  using PagedList;

    public class FeesCommissionsController : Controller
    {
        private DunsmoreContext db = new DunsmoreContext();

        public ActionResult Index()
        {
            List<FeesCommissions> ListFeesCommissions = db.FeesCommissions.ToList();
            return View(ListFeesCommissions);
        }

        //
        // GET: /FeesCommissions/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /FeesCommissions/Create

        public ActionResult Create()
        {
          FeesCommissions fc = new FeesCommissions();
            return View(fc);
        }

        //
        // POST: /FeesCommissions/Create

        [HttpPost]
        public ActionResult Create(FeesCommissions fc)
        {
            try
            {
              db.FeesCommissions.Add(fc);
                db.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /FeesCommissions/Edit/5

        public ActionResult Edit(int id)
        {
          FeesCommissions fc = db.FeesCommissions.Find(id);
          ViewBag.CallCentreID = new SelectList(db.CallCentres, "CallCentreID", "Contact1", fc.CallCentreID);
          ViewBag.SectorID = new SelectList(db.Sectors, "SectorID", "Sector",fc.SectorID);
          ViewBag.LeadFlagsID = new SelectList(db.LeadFlags.OrderBy(m => m.DisplayOrder), "LeadFlagsID", "Description",fc.LeadFlagsID);

          return View(fc);
        }

        //
        // POST: /FeesCommissions/Edit/5

        [HttpPost]
        public ActionResult Edit(FeesCommissions fc)
        {
            try
            {
              db.Entry(fc).State = EntityState.Modified;
              db.SaveChanges();

              return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /FeesCommissions/Delete/5

        public ActionResult Delete(int id)
        {
            return View(db.FeesCommissions.Find(id));
        }

        //
        // POST: /FeesCommissions/Delete/5

        [HttpPost]
        public ActionResult Delete(FeesCommissions fc)
        {
            try
            {
              FeesCommissions fcd = db.FeesCommissions.Find(fc.FeesCommissionsID);
              db.FeesCommissions.Remove(fcd);
              db.SaveChanges();
              return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
